package com.sw.youvote.client.areas;

import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.sw.youvote.client.QuizListGUI;
import com.sw.youvote.client.services.WocomUserServiceDelegate;

public class HeadArea {

	private static final String LOGO_URL = "youvote/gwt/standard/images/Wocom.png";
	
	private Label headerLabel;
	private Image logo;
	private VerticalPanel panel;
	private Label userName;
	private WocomUserServiceDelegate delegate;
	private QuizListGUI gui;
	
	public HeadArea(QuizListGUI parentGUI){
	
	this.gui = parentGUI;
	delegate = new WocomUserServiceDelegate();
	delegate.setGUI(parentGUI);
	delegate.pintaCadenaLogin();
	
	/* WIDGET - LABEL HEADER */
	headerLabel = new Label("Tus concursos");
	headerLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
	headerLabel.setStylePrimaryName("headerLabel");
	userName = new Label();
	
	
	// WIDGET - LOGO HEADER
	logo = new Image(LOGO_URL); 
	panel = new VerticalPanel();
  	// PANEL - HEADER
	panel.setWidth("100%");
	panel.setStylePrimaryName("header");
	panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
	panel.add(userName);
	panel.add(logo);
	// headerPanel.add(headerLabel);
	// headerPanel.add(status);
	}
	
	public VerticalPanel getPanel(){
		return panel;
	}
	
 	public void service_eventGetUserNameFromService(String userNameRetrieved) {
        userName.setText(userNameRetrieved);
    }
 
    public void service_eventGetUserNameFailed(Throwable caught) {
        userName.setText("Error");
    }
    
    public void service_eventEstaLogadoFromService(String userNameRetrieved) {
        userName.setText(userNameRetrieved);
    }
 
    public void service_eventEstaLogadoFailed(Throwable caught) {
        userName.setText("Error");
    }
}
